package com.flybutter.usagelab.repository

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase

private var appDatabase: AppDatabase? = null

fun Context.getAppDataBase(): AppDatabase{
    if (appDatabase == null){
        appDatabase = Room.databaseBuilder(this,AppDatabase::class.java,
            "appDatabase").build()
    }
    return appDatabase!!
}

@Database(entities = [UsageInfo::class,ScreenUsageInfo::class], version = 2)
abstract class AppDatabase: RoomDatabase() {
    abstract fun getUseStateDao(): UsageInfoDao

    abstract fun getScreenUsageDao(): ScreenUsageDao
}